<?php
require_once("../config.php");
//if(!isset($_SESSION['admin_user'])) header("location:index.php");
//require_once(CONSTANT."alltype.php");
//page_constant("admin");

$tpl->assign("type_brand",$type_brand_c);

$dsql->setquery("select * from alltype where belongto in ('name_en','name_cn','country','level','product_line')");
$dsql->Execute();
while($row=$dsql->GetArray())
	$brand[]=$row;
$tpl->assign("brand",$brand);

if(isset($_POST) and !empty($_POST))
{
	$postarray=$_POST;
	$uid=new UID();
	if(!empty($_GET['id']))  //update
	{
		$uid->update("brand",$postarray,"id =".$_GET['id']);
		$tpl->assign("msg",2);
	}
	else   //add
	{
	
	//var_dump($postarray);
	
	$uid->insert("brand",$postarray);
	$tpl->assign("msg",1);
	}
}
if(!empty($_GET['id']))
{
	$dsql->setquery("select * from brand where id = ".$_GET['id']);
	$dsql->Execute();
	while($row=$dsql->GetArray())
		$brand_text=$row;
	$tpl->assign("brand_text",$brand_text);
}
//var_dump($brand_text);
$tpl->display("admin_brand.tpl");
?>